package cn.tedu._03vehicle.base.interceptors;


import cn.tedu._03vehicle.pojo.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录转态拦截器
 */
@Slf4j
public class LoginCheckInterceptro implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.debug("进入校验登录状态拦截器。。。");
        //先获取会话对象
         UserVO userVO = (UserVO) request.getSession().getAttribute("user777888XXX");
         if (userVO == null) {
             //用户未登录
             response.sendRedirect("/login.html");
             return false;
         }else {
             //用户已登录
             return true;
         }
    }
}
